package tree;
/*二叉树
* */
public class ReviewBinaryTree<T> {
    private int id;
    private T data;
    private ReviewBinaryTree left;
    private ReviewBinaryTree right;

    public ReviewBinaryTree(){};
    public ReviewBinaryTree(int id,T data){
        this.id = id;
        this.data = data;
    }
    //前序遍历
    public static void preOrder(ReviewBinaryTree treeNode){
        if (treeNode == null){
            return;
        }
        System.out.print(treeNode.id);
        preOrder(treeNode.left);
        preOrder(treeNode.right);
    }
    //前序遍历查找
    public static ReviewBinaryTree preOrderSearch(ReviewBinaryTree treeNode,int target){
        if (treeNode == null){
            return null;
        }
        if (treeNode.id == target){
            return treeNode;
        }
        ReviewBinaryTree temp  = new ReviewBinaryTree();
        temp = preOrderSearch(treeNode.left,target);
        if (temp.id == target){
            return temp;
        }
        temp = preOrderSearch(treeNode.right,target);
        return temp;
    }

    public static void main(String[] args) {

    }
}
